package com.example.light.web.system.dao;

import com.example.light.web.system.entity.Department;
import com.example.light.web.system.entity.Role;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface RoleMapper {
    int deleteByPrimaryKey(Integer roleId);

    Role selectByPrimaryKey(Integer roleid);

    @Results(id="RoleResults",value = {
            @Result(property = "roleId",column = "role_id"),
            @Result(property = "roleName",column = "role_name"),
            @Result(property = "createTime",column = "role_create_time"),
            @Result(property = "roleMemo",column = "role_memo")
    })
    @Select("select * from role")
    public List<Role> Queryall();

    @Insert("insert into role(role_id,role_name,role_memo,role_create_time) " +
            "values(#{roleId},#{roleName},#{roleMemo},#{createTime})")
    int add(Role record);

    @Update("update role set role_name=#{roleName},role_memo=#{roleMemo},role_create_time=#{createTime}" +
            " where role_id=#{roleId}")
    public int update(Role dept);

    @ResultMap("RoleResults")
    @Select("select * from role " +
            "where role_name = #{roleName}")
    public Role selectRoleId(String roleName);
}